from gxl_ai_utils.utils import utils_file
true_file, test_data_dir = utils_file.do_get_commandline_param(2, ["true_file", "test_data_dir"])



input_file = f"{test_data_dir}/new_context_asr/test/step_16249/long_think_no_punctuation/info_res.scp"
# true_file = f"{test_data_dir}/test_text.scp"
output_wer_dir = f"{test_data_dir}/new_context_asr/test/step_16249/long_think_no_punctuation"
utils_file.do_compute_wer(input_file,true_file, output_wer_dir)
output_wer_file = output_wer_dir + "/wer"
lines_tmp = utils_file.load_list_file_clean(output_wer_file)
utils_file.print_list(lines_tmp[-10:])


input_file = f"{test_data_dir}/new_context_asr/test/step_16249/medium_think_no_punctuation/info_res.scp"
# true_file = f"{test_data_dir}/test_text.scp"
output_wer_dir = f"{test_data_dir}/new_context_asr/test/step_16249/medium_think_no_punctuation"
utils_file.do_compute_wer(input_file,true_file, output_wer_dir)
output_wer_file = output_wer_dir + "/wer"
lines_tmp = utils_file.load_list_file_clean(output_wer_file)
utils_file.print_list(lines_tmp[-10:])

input_file = f"{test_data_dir}/new_context_asr/test/step_16249/short_think_no_punctuation/info_res.scp"
# true_file = f"{test_data_dir}/test_text.scp"
output_wer_dir = f"{test_data_dir}/new_context_asr/test/step_16249/short_think_no_punctuation"
utils_file.do_compute_wer(input_file,true_file, output_wer_dir)
output_wer_file = output_wer_dir + "/wer"
lines_tmp = utils_file.load_list_file_clean(output_wer_file)
utils_file.print_list(lines_tmp[-10:])

input_file = f"{test_data_dir}/new_context_asr/test/step_16249/no_think_no_punctuation/info_res.scp"
info_dict = utils_file.load_dict_from_scp(input_file)
for key, value in info_dict.items():
    if "<中立>" in value:
        value = value.replace("<中立>", "")
        info_dict[key] = value
utils_file.write_dict_to_scp(info_dict, input_file)
# true_file = f"{test_data_dir}/test_text.scp"
output_wer_dir = f"{test_data_dir}/new_context_asr/test/step_16249/no_think_no_punctuation"
utils_file.do_compute_wer(input_file,true_file, output_wer_dir)
output_wer_file = output_wer_dir + "/wer"
lines_tmp = utils_file.load_list_file_clean(output_wer_file)
utils_file.print_list(lines_tmp[-10:])
